package com.itheima.user.service.impl;

import com.itheima.common.utils.MD5Utils;
import com.itheima.pojo.Member;
import com.itheima.user.mapper.MemberMapper;
import com.itheima.user.service.MemberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class MemberServiceImpl implements MemberService {

    @Autowired
    private MemberMapper memberMapper;
    //根据手机号查询会员
    public Member findByTelephone(String telephone) {
        return memberMapper.findByTelephone(telephone);
    }
    //新增会员
    public void add(Member member) {
        if(member.getPassword() != null){
            member.setPassword(MD5Utils.md5(member.getPassword()));
        }
        memberMapper.add(member);
    }
}
